var flag = 0;
      function editRow(element,id) {
   

		var count = 0;
		$(element).parent().parent().children("td").each(function(){
			 if(count < 4) {
				 if(count!=0){
				$(this).html('<input type="text" style="width: 200px;" id="text'+count+'" value="'+$(this).html()+'"/>');

				 }
			} 
            count++; 
			flag=1;
		});		
		 $(element).attr("disabled", true);
	}


	function saveData(element, id)
		{ 
			
var statusID=$("#"+id).val();
 if(statusID==1)
		{
var questId;
var courseId;
var quest;
var answ;

var args=new Array();
var count = 0;

    if (flag==0)
     {
	 $(element).parent().parent().children("td").each(function(){
			if(count < 4) {
	                args[count]=$(this).html();
                    }
			count++;
			
		});	
 
          questId = args[0];
		  courseId = args[1];
		  quest = args[2];
		  answ = args[3];

flag=1;
}

else{
           questId = $(element).parent().parent().children("td").html();
		   courseId = $("#text1").val();
		   quest = $("#text2").val();
		   answ = $("#text3").val();
 }
var dataString ="courseid="+courseId+"&questid="+questId+"&Quest="+quest+"&Answ="+answ+"&StatusId="+statusID;
    
          
          $.ajax({
          type:'POST',
	 	  url: "../updatequestions",
		  data:dataString,

     success: function(result){
		  
		  
       if($.trim(result) == "1"){
		   
			 alert("Data Submitted Successfully for Quest. No "+questId);
			 window.location.href = self.location.href;
			            }
						else{
						window.location.href = self.location.href;
						}
   
              } 
                           

         });
}
}